package cc.comac.mom.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipDevCategoryService;
import cc.comac.mom.bean.EquipDevCategory;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.datahandlers.entity.EquipDevCategoryDataHandler;
import cc.comac.mom.util.ResultBean;
@Service
@RestController
public class EquipDevCategoryServiceImpl implements EquipDevCategoryService {

	@Autowired
	private EquipDevCategoryDataHandler equipDevCategoryDataHandler;
	
	
	@Override
	public ResultBean insert(@RequestBody EquipDevCategory equipDevCategory) {
		ResultBean resultBean = new ResultBean(true);
		resultBean.setObject(equipDevCategoryDataHandler.insert(equipDevCategory));
		return resultBean;
	}

	@Override
	public ResultBean update(@RequestBody EquipDevCategory equipDevCategory) {
		ResultBean resultBean = new ResultBean(true);
		equipDevCategoryDataHandler.update(equipDevCategory);
		return resultBean;
	}

	@Override
	public ResultBean batchDelete(@RequestBody List<EquipDevCategory> list) {
		ResultBean resultBean = new ResultBean(true);
		equipDevCategoryDataHandler.batchDelete(list);
		return resultBean;
	}

	@Override
	public ResultDev selectByFields(@RequestBody EquipDevCategory equipDevCategory) {
		
		ResultDev selectByFields = null;
		if (equipDevCategory.getSearchAll() != 1) {
			 selectByFields = equipDevCategoryDataHandler.selectByFields(equipDevCategory);
		} else {
			selectByFields = equipDevCategoryDataHandler.selectAll();
		}
		return selectByFields;
	}

	@Override
	public ResultDev selectAll() {
		ResultDev selectAll = equipDevCategoryDataHandler.selectAll();
		return selectAll;
	}
	

}
